package models;

public class UsuarioLinkList {
	private UsuarioLink first;

	public UsuarioLinkList(){
		first = null;
	}
	
	public void insert(UsuarioLink key_link){
		if(first == null){
			first = key_link;
		}
		else{
			key_link.setNext(first);
			first = key_link;
		}
	}
	
	public UsuarioLink find(String key_login, String key_senha){
		UsuarioLink current = first;
		
		while(key_login.compareTo(current.getLogin()) != 0 && key_senha.compareTo(current.getSenha()) != 0)
		{
			if(current.getNext() == null){
				return null;
			}
			else{
				current = current.getNext();
			}
		}
		return current;
	}
	
	public UsuarioLink find(String key_nome){
		UsuarioLink current = first;
		
		while(key_nome.compareTo(current.getLogin()) != 0)
		{
			if(current.getNext() == null){
				return null;
			}
			else{
				current = current.getNext();
			}
		}
		return current;
	}
	
	public UsuarioLink find(int key_cliente_id){
		UsuarioLink current = first;
		
		while(current.getUsuarioId() != key_cliente_id)	{
			if(current.getNext() == null){
				return null;
			}
			else{
				current = current.getNext();
			}
		}
		return current;
	}
	
	public boolean isEmpty(){
		return (first == null);
	}
}